<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>注册</title>
<link href="css/base.css" rel="stylesheet" type="text/css">
<link href="css/css.css" rel="stylesheet" type="text/css">
<script src="js/jquery-2.1.1.min.js"></script>
<style>
.tab {
	overflow: hidden;
	margin-top: 20px; margin-bottom:-1px;
}
.tab li {
	display: block;
	float: left;
	width: 100px;padding:10px 20px; cursor:pointer; border:1px solid #ccc; 
}
.tab li.on {
	background: #90B831; color:#FFF;padding:10px 20px;
}
.conlist {padding:30px; border:1px solid #ccc; width:300px;}
.conbox {
	display: none;
}
</style>
<script>
$(function(){
	$(".tab li").each(function(i){
		$(this).click(function(){
		$(this).addClass("on").siblings().removeClass("on");
		$(".conlist .conbox").eq(i).show().siblings().hide();
		})
	})
})
</script>

    <script>
  function myregister(){
      //获取用户名和密码以及确认密码
      var myname=$("#myname").val();
      var mypwd=$("#mypwd").val();
      var mypwd2=$("#mypwd2").val();

     if(myname!=""&&mypwd!=""&&mypwd2!=""&&(mypwd==mypwd2)){
         //注册
          $.ajax({
              url: "http://localhost:8088/UniverseFarmBack/register.do",
              dataType:"json",
              data:{name:myname,pwd:mypwd},
              type:"get",
              xhrFields: {                               //保存session在跨域访问中不会丢失！！！
                  withCredentials: true
              },
              crossDomain: true,
              success:function(result){
                  if(result.flag==0){
                      alert(result.msg);
                  }
                  else{
                      alert(result.msg);
                      //跳转到登录页面进行登录
                      location.href='login.html';
                  }
              }


          });

     }
     else {
         alert("输入为空或两次密码不一致!!!");
     }

  }



    </script>
</head>

<body class="l-bg">
<div class="login-top">
    <div class="wrapper">
        <div class="fl font30">LOGO</div>
        <div class="fr">您好，欢迎为生活充电在线！</div>
    </div>
</div>
<div class="l_main2">
    <div class="l_bttitle"> 
        <h2>注册</h2>
    </div>
    <div class="loginbox">
        <div class="tab">
            <ul>
                <li class="on">我是买家</li>
            </ul>
        </div>
        <div class="conlist">
            <div class="conbox" style="display:block;">
                <p>
                    <div class="fl res-text">用户名：</div><div><input type="text" class="loginuser" id="myname"></div>
                </p>
                <p>
                   <div class="fl res-text">密码：</div><div><input type="password" class="loginuser" id="mypwd"></div>
                </p>
                <p>
                   <div class="fl res-text">确认密码：</div><div><input type="password" class="loginuser" id="mypwd2"></div>
                </p>

                <p>
                    <input type="button" class="loginbtn" value="注 册" onclick="myregister()">
                </p>
            </div>

        </div>
    </div>
</div>
</body>
</html>
